import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../manager/app_manager.dart';
import '../../model/cart.dart';
import 'home_cart_list_item.dart';

class HomeCartListPanel extends ConsumerWidget {
  const HomeCartListPanel({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    print("HomeCartListPanel build ...");
    final carts = ref.watch(AppManager.shared.provider.select((value) => value.carts));
    return ListView.builder(
      itemCount: carts.length,
      itemExtent: HomeCartListItem.itemHeight,
      itemBuilder: (context,index) {
        Cart cart = carts[index];
        return HomeCartListItem(
          cart: cart,
        );
      },
    );
  }
}
